/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package model.service;

import java.sql.Connection;
import java.sql.Statement;
import model.dao.PDAConexion;
import util.jdbc.ConexionSQLite;
import model.domain.bd.BaseDatos;

/**
 *
 * @author Rdelacruz
 */
public class PDAService {
  
    
    public void borrarTablas_SQLite(BaseDatos bd) throws Exception {        
        Connection con = PDAConexion.getConexion();
        Statement st = con.createStatement();
        String sql = bd.scriptsDropTableIfExits();
        st.executeUpdate(sql);
        st.close();
        con.close();
    }

    public void crearTablas_SQLite(BaseDatos bd) throws Exception {        
        Connection con = PDAConexion.getConexion();
        Statement st = con.createStatement();
        String sql = bd.scriptsCreateTableIfNoExits();
        st.executeUpdate(sql);
        st.close();
        //con.commit();
        con.close();        
    }
    
    public void insertarData_SQLite(BaseDatos bd) throws Exception {
        Connection con = PDAConexion.getConexion(false);
        Statement st = con.createStatement();
        String sql = bd.scriptsInsert();
        //System.out.println(sql);
        st.executeUpdate(sql);
        st.close();
        con.commit();
        con.close();
    }
}
